﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace WorkStation.Frameworks.Configuration.Elements
{
    /// <summary>
    /// * 配置节集合基类
    /// </summary>
    /// <typeparam name="TConfiguration">配置节类型</typeparam>
    [Serializable]
    public abstract class BaseConfigurationCollection<TConfiguration> where TConfiguration : IConfiguration
    {
        protected List<TConfiguration> _list = new List<TConfiguration>();

        public TConfiguration this[string name]
        {
            get
            {
                return this._list.FirstOrDefault(v => v.Name.Equals(name));
            }
        }

        [XmlIgnore]
        public List<string> Keys
        {
            get
            {
                return this._list.Select(v => v.Name).ToList();
            }
        }
    }
}
